﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Bing.Maps;
using MenusHunter.WinRT.Core.MVVM;
using MenusHunter.WinRT.Core.Models;
using MenusHunter.WinRT.Core.Services.Food;
using MenusHunter.WinRT.Core.Services.Restaurant;
using Windows.Devices.Geolocation;
using Windows.UI.Xaml;

namespace MenusHunter.WinRT.Core.ViewModels
{
    public class ViewMapPageViewModel : ViewModelBase
    {
        private Geocoordinate _currentLocation;
        private ObservableCollection<Restaurant> _restaurants;
        private Geolocator _localtor;
        private ObservableCollection<Food> _foodsOfRestaurant;

        public Geocoordinate CurrentLocation
        {
            get { return _currentLocation; }
            set { SetProperty(ref _currentLocation, value); }
        }

        public ObservableCollection<Restaurant> Restaurants
        {
            get { return _restaurants; }
            set { SetProperty(ref _restaurants, value); }
        }
        public ObservableCollection<Food> FoodsOfRestaurant
        {
            get { return _foodsOfRestaurant; }
            set { SetProperty(ref _foodsOfRestaurant, value); }
        }

        public ViewMapPageViewModel()
        {
                
        }
        public async void GetListRestaurants()
        {
            IsBusy = true;
            var result = await RestaurantsManager.GetListRestaurantAsync();
            Restaurants = result;
            IsBusy = false;
        }

        public async Task<ObservableCollection<Restaurant>>  GetListRestaurantsAround(double currenLat, double currentLong, int offset, int limit, int radius = 2)
        {
            IsBusy = true;
            var result =
                await RestaurantsManager.GetListRestaurantAroundAsync(currenLat, currentLong, radius, offset, limit);
           
            IsBusy = false;
            return result;
        }
        public async Task GetFoodsForRestaurant(int resID)
        {
            IsBusy = true;
            var result = await FoodsManager.GetListFoodRestaurant(resID);
            IsBusy = false;
            FoodsOfRestaurant = result;
        }

       
    }
}